﻿using MyToDo.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyToDo.ViewModels
{
    public class ToDoViewModel : BindableBase
    {
        public ToDoViewModel()
        {
            ToDoItems = new ObservableCollection<ToDoItem>();
            CreateToDoList();
            AddToDoCommand = new DelegateCommand(Add);
        }

        public void Add()
        {
            IsRightDrawerOpen = !IsRightDrawerOpen;
        }

        private bool isRightDrawerOpen;
        /// <summary>
        /// 右侧编辑窗口展开
        /// </summary>
        public bool IsRightDrawerOpen
        {
            get { return isRightDrawerOpen; }
            set { isRightDrawerOpen = value;  RaisePropertyChanged(); }
        }
        public DelegateCommand AddToDoCommand { get; set; }

        private ObservableCollection<ToDoItem> toDoItems;
        public ObservableCollection<ToDoItem> ToDoItems
        {
            get { return toDoItems; }
            set
            {
                toDoItems = value;
                RaisePropertyChanged();
            }
        }

        void CreateToDoList()
        {
            for (int i = 0; i < 20; i++)
            {
                ToDoItems.Add(new ToDoItem()
                {
                    Title = "标题" + i,
                    Content = "测试数据..."
                });


            }
        }

    }
}
